<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>linux 作业题 | 个人博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="categories: MySql数据库linux 作业题 搭建一个MySQL高可用架构集群环境（4台主机，1主、2从、1 MHA）   如上图 CoderCheng 为主库    UCloud  和 UCloud1年  为两个从库 以dept 为库为演示        从库 和主库 目前只要这几条数据  现在 我在主库添加一条数据 id为4    name的5数据  刷新从库 可以看到 数据已">
<meta property="og:type" content="article">
<meta property="og:title" content="linux 作业题">
<meta property="og:url" content="http://codercheng.cn/2020/12/18/linux%20%E4%BD%9C%E4%B8%9A%E9%A2%98/index.html">
<meta property="og:site_name" content="个人博客">
<meta property="og:description" content="categories: MySql数据库linux 作业题 搭建一个MySQL高可用架构集群环境（4台主机，1主、2从、1 MHA）   如上图 CoderCheng 为主库    UCloud  和 UCloud1年  为两个从库 以dept 为库为演示        从库 和主库 目前只要这几条数据  现在 我在主库添加一条数据 id为4    name的5数据  刷新从库 可以看到 数据已">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/165713-354069.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170115-644437.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171449-724149.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171436-319152.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170801-195533.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170922-801950.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170947-620462.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171031-566571.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/090608-553293.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/084940-376922.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/091136-580829.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/091935-930142.png">
<meta property="og:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/092100-605003.png">
<meta property="article:published_time" content="2020-12-18T08:49:33.206Z">
<meta property="article:modified_time" content="2021-03-03T07:29:21.892Z">
<meta property="article:author" content="CoderCheng">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/165713-354069.png">
  
    <link rel="alternate" href="/atom.xml" title="个人博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.lug.ustc.edu.cn/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">个人博客</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://codercheng.cn"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-linux 作业题" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2020/12/18/linux%20%E4%BD%9C%E4%B8%9A%E9%A2%98/" class="article-date">
  <time datetime="2020-12-18T08:49:33.206Z" itemprop="datePublished">2020-12-18</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      linux 作业题
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="categories-MySql数据库"><a href="#categories-MySql数据库" class="headerlink" title="categories: MySql数据库"></a>categories: MySql数据库</h2><p>linux 作业题</p>
<p><strong>搭建一个MySQL高可用架构集群环境（4台主机，1主、2从、1 MHA）</strong></p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/165713-354069.png" alt="image-20201218165712462"></p>
<p> 如上图 CoderCheng 为主库    UCloud  和 UCloud1年  为两个从库</p>
<p>以dept 为库为演示    </p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170115-644437.png" alt="image-20201218170115160"></p>
<p>  从库 和主库 目前只要这几条数据  现在 我在主库添加一条数据</p>
<p>id为4    name的5数据</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171449-724149.png" alt="image-20201218170611409"></p>
<p>刷新从库 可以看到 数据已经同步过来了 </p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171436-319152.png" alt="image-20201218170740855"></p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170801-195533.png" alt="image-20201218170800466"></p>
<p>说明 主从同步成功</p>
<p> 以下命名在主库用到命令</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170922-801950.png" alt="image-20201218170921953"></p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/170947-620462.png" alt="image-20201218170947061"></p>
<p>以下命令从库 用到</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/18/171031-566571.png" alt="image-20201218171031275"></p>
<p>说明满足主从 半同步复制。</p>
<p> 接下来 测试mha功能  </p>
<p>备注  </p>
<p>39.106.214.114  master</p>
<p>106.75.20.63     slave</p>
<p>117.50.7.7     slave</p>
<p>106.75.31.205   manager </p>
<ul>
<li><p>首先4台机器进行ssh免密登录  </p>
<p>配置完成后使用命令测试</p>
</li>
</ul>
  <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">masterha_check_ssh -conf=/etc/mha_master/mha.cnf</span><br></pre></td></tr></table></figure>

<p>  出现下图所示代表ssh 免密成功</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/090608-553293.png" alt="image-20201219084600607"></p>
<ul>
<li><p>进行主从复制测试（出现下图表示成功）</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">masterha_check_repl <span class="literal">-conf</span>=/etc/mha_master/mha.cnf &gt; /etc/mha_master/manager.log &amp;</span><br></pre></td></tr></table></figure>

<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/084940-376922.png" alt="image-20201219084939148"></p>
</li>
<li><p>接下来 启动 manager管理节点查看主从切换日志</p>
</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">masterha_manager --conf=/etc/mha_master/mha.cnf &lt; /etc/mha_master/manager.log &amp;</span><br></pre></td></tr></table></figure>

<p>​       接下来手动关闭  39.106.214.114  模拟故障  master mysql  查看 manager日志</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/091136-580829.png" alt="image-20201219091135589"></p>
<p>  出现  这个 成功 说明   已经  mha 切换可以成功</p>
<p>   下面在新的master添加一条数据 测试 是否成成功</p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/091935-930142.png" alt="image-20201219091935067"></p>
<p>​    开始在新的master（Ucloud）添加一条 id 888  name 666的数据  刷新 slave （UCloud1年）库查看数据  </p>
<p><img src="https://gitee.com/adc123321/blog_img/raw/master/image/202012/19/092100-605003.png" alt="image-20201219092058063"></p>
<p><strong>测试成功！！！</strong></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://codercheng.cn/2020/12/18/linux%20%E4%BD%9C%E4%B8%9A%E9%A2%98/" data-id="cko3snvx30012i8uofgekctt9" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2020/12/25/%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8%E5%AE%9E%E6%88%98%E5%8F%8A%E4%B8%AD%E9%97%B4%E4%BB%B6/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          分库分表实战及中间件
        
      </div>
    </a>
  
  
    <a href="/2020/12/16/Linux%20%E4%B8%80%E4%BA%9B%E5%91%BD%E4%BB%A4/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Linux 一些命令</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/MySql/">MySql</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Netty/">Netty</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/SpringBoot/">SpringBoot</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/SpringCloud/">SpringCloud</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/SpringMVC/">SpringMVC</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Tomcat/">Tomcat</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Zookeeper/">Zookeeper</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E4%BD%9C%E4%B8%9A/">作业</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%88%86%E5%B8%83%E5%BC%8F%E8%B0%83%E5%BA%A6/">分布式调度</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%A1%86%E6%9E%B6/">框架</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%9F%A5%E8%AF%86/">知识</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2024/08/">八月 2024</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/09/">九月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/08/">八月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/04/">四月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/02/">二月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/11/">十一月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/06/">六月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/05/">五月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/04/">四月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">三月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/02/">二月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/01/">一月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/12/">十二月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/11/">十一月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/10/">十月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/09/">九月 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">八月 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2024/08/28/CentOS%E5%86%85%E5%AD%98cpu%E6%8E%92%E6%9F%A5/">CentOS内存cpu排查</a>
          </li>
        
          <li>
            <a href="/2022/09/22/Linux%20%E6%9F%A5%E7%9C%8B%E6%97%A5%E5%BF%97%E5%91%BD%E4%BB%A4/">Linux 查看日志命令</a>
          </li>
        
          <li>
            <a href="/2022/08/30/dubbo%20%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98/">dubbo 常见问题</a>
          </li>
        
          <li>
            <a href="/2022/04/26/1%20%E6%BA%90%E7%A0%81%E7%AC%94%E8%AE%B0/">1 源码笔记</a>
          </li>
        
          <li>
            <a href="/2022/02/24/jvisualVM%20%E4%BD%BF%E7%94%A8%E7%AC%94%E8%AE%B0/">jvisualVM 使用笔记</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2024 CoderCheng<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>